package top.fkxuexi.blogapi.modules.auth.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import top.fkxuexi.blogapi.core.utils.common.Code;
import top.fkxuexi.blogapi.core.utils.common.Page;
import top.fkxuexi.blogapi.core.utils.common.Result;
import top.fkxuexi.blogapi.modules.auth.service.SysUserService;

/**
 * @Author blog.fkxuexi.top
 * @Gitee: https://gitee.com/smartwork/
 * @Descri: 系统用户表
 */

@Api(description = "系统管理员列表操作")
@Controller
@RequestMapping(value = "/admin/user/")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @ApiOperation(value = "获取管理员列表",notes = "获取所有管理员列表")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public Result list(@ApiParam("页码,必传") @RequestParam(value = "index") Integer index,
                       @ApiParam("页面大小,必传") @RequestParam(value = "size") Integer size,
                       @ApiParam("用户昵称，选传")  @RequestParam(value = "nickName", required = false) String nickName,
                       @ApiParam("电话号码,选传") @RequestParam(value = "phone", required = false) String phone,
                       @ApiParam("用户状态，选传") @RequestParam(value = "status",required = false)Integer status) {

        //1：启用，2：冻结，3：删除
        Page page = sysUserService.list(index, size, nickName, phone,status);
        return new Result(Code.SUCCESS,true,page);
    }

}